package cn.edu.scnu.semart.order.service;

import cn.edu.scnu.semart.model.order.PaymentRecord;
import cn.edu.scnu.semart.order.mapper.PaymentRecordMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class PaymentService {
    private final PaymentRecordMapper paymentRecordMapper;

    @Transactional
    public void createPayment(String orderNumber, BigDecimal amount) {
        PaymentRecord record = new PaymentRecord();
        record.setOrderNumber(orderNumber);
        record.setAmount(amount);
        record.setPaymentMethod("alipay");
        record.setStatus("pending");
        record.setCreateTime(new Date());

        paymentRecordMapper.insert(record);
    }

}
